﻿using System;

namespace DnEcuDiag.Conversion
{
    class M2104Conversion : IsoConvertor, IConvertor
    {
        #region IConvertor Members

        public float Convert(int conversionId, byte[] rawData)
        {
            float result = 0;
            UInt32 rawValue = ConvertByteArray(rawData);

            switch (conversionId)
            {
                case 10:
                    result = CalculateRpm(rawData);
                    break;
                case 11:
                    result = rawValue * 10;
                    break;
                case 12:
                    result = M2104TempTableRam[rawValue];
                    break;
                case 13:
                    result = rawValue * 96 / 230.4f;
                    break;
                case 14:
                    result = rawValue * 1.6f;
                    break;
                case 15:
                    result = rawValue * 0.2f;
                    break;
                case 16:
                    result = 78 - (rawValue * 0.75f);
                    break;
                case 17:
                    result = rawData[0] * 0.384f + rawData[1] / 255f;
                    break;
                case 18:
                    result = rawValue / 255f;
                    break;
                case 19:
                    result = rawValue * 96 / 230.4f;
                    break;
                case 20:
                    result = rawValue * 0.05f;
                    break;
                case 21:
                    result = rawValue * 5f;
                    break;
                case 22:
                    result = rawValue * 0.20f;
                    break;
                case 23:
                    result = rawValue * 5 / 255f;
                    break;
                case 24:
                    result = rawValue * 0.0705f;
                    break;
                case 25:
                    result = rawValue;
                    break;
                case 26:
                    result = (rawValue * 1.25f) / 255;
                    break;
                case 27:
                    result = (rawData[0] - 0x80) * 0.8f;
                    break;
                case 28:
                    result = (rawData[0] - 0x80) * 0.8f;
                    break;
                case 29:
                    result = (rawData[0] - 0x80) * 2f;
                    break;
                case 30:
                    result = (rawData[0] - 0x80) * 2f;
                    break;
                case 31:
                    result = rawValue * 10;
                    break;
                case 32:
                    result = rawValue * 0.39f;
                    break;
                case 33:
                    result = rawValue * 0.1f;
                    break;
                case 34:
                    result = rawValue * 40;
                    break;
                case 35:
                    result = rawValue * 96 / 230.4f;
                    break;
                case 36:
                    result = rawValue / 14.68f;
                    break;
                case 37:
                    result = rawValue * 5f / 255;
                    break;
                case 38:
                    result = M2104TempTableAdc[rawValue];
                    break;
                case 39:
                    result = rawValue * 5f / 255;
                    break;
                case 40:
                    result = rawValue * 5000f / 255;
                    break;
                case 41:
                    result = rawValue * 1250f / 255;
                    break;
                case 42:
                    result = rawValue * 5f / 255;
                    break;
                case 43:
                    result = rawValue / 14.68f;
                    break;
                case 44:
                    result = rawValue;
                    break;
            }

            return result;
        }

        #endregion
    }
}
